<template>
  <div class="MyHandoverScreen">
    <van-row>
      <van-col span="15">
        <div class="MyHandoverScreenItem">
          <h1>发货单：</h1>
          <p>{{ data.deliverCargoNo }}</p>
        </div>
      </van-col>
      <van-col span="9">
        <div class="MyHandoverScreenItem">
          <h1>发货类型：</h1>
          <p>{{ data.deliverGoodsType | deliverGoodsTypeShow }}</p>
        </div>
      </van-col>
      <van-col span="15">
        <div class="MyHandoverScreenItem">
          <h1>联系方式：</h1>
          <p>{{ data.contactNumber }}</p>
        </div>
      </van-col>
      <van-col span="9">
        <div class="MyHandoverScreenItem">
          <h1>提 &nbsp;货&nbsp; 口：</h1>
          <p>{{ data.export | filterExportCargo(exportCargo) }}</p>
        </div>
      </van-col>
      <van-col span="15">
        <div class="MyHandoverScreenItem">
          <h1>提货单位：</h1>
          <p style="white-space:normal">{{ data.consigneeCompanyName }}</p>
        </div>
      </van-col>

      <van-col span="9">
        <div class="MyHandoverScreenItem">
          <h1>提 &nbsp;货&nbsp; 人：</h1>
          <p>{{ data.consigneeName }}</p>
        </div>
      </van-col>
      <van-col span="15">
        <div class="MyHandoverScreenItem">
          <h1>车 &nbsp;牌&nbsp; 号：</h1>
          <p>{{ data.carNum }}</p>
        </div>
      </van-col>
      <van-col span="9">
        <div class="MyHandoverScreenItem">
          <h1>装车服务：</h1>
          <p class="red">{{ data.loadingService == 1 ? "是" : "否" }}</p>
        </div>
      </van-col>
    </van-row>

    <van-row gutter="10">
      <van-col span="6">
        <van-button
          block
          size="small"
          class="button"
          round
          @click="openStartScan"
        >
          交接扫描
        </van-button>
      </van-col>
      <van-col span="6">
        <van-button
          block
          size="small"
          class="button"
          round
          @click="showRegistration"
          >破损登记</van-button
        >
      </van-col>
      <van-col span="6">
        <van-button
          block
          size="small"
          class="button1"
          round
          @click="cancelHandover"
          >取消交接</van-button
        >
      </van-col>
      <van-col span="6">
        <van-button
          block
          size="small"
          class="button1"
          round
          @click="holdCompleteHandover"
          >暂存</van-button
        >
      </van-col>
    </van-row>
  </div>
</template>

<script>
import Vue from "vue";
import { Col, Row, Button, Stepper, Toast } from "vant";
import { cancelHandover } from "../services/api";
Vue.use(Col);
Vue.use(Row);
Vue.use(Button);
Vue.use(Stepper);
export default {
  props: ["data", "exportCargo"],
  methods: {
    // 调用摄像头扫码
    openStartScan(e) {
      try {
        window.appPlat.startScan();
      } catch (e) {
        Toast("设备不支持");
      }
    },
    // 开启破损登记
    showRegistration() {
      this.$emit("showRegistration");
    },
    // 取消交接
    cancelHandover() {
      cancelHandover({
        deliverCargoBillId: this.$route.params.id,
      }).then((res) => {
        try {
          window.appPlat.goBack();
        } catch (e) {
          this.$router.go(-1);
        }
      });
    },
    // 暂存
    holdCompleteHandover(){
       this.$emit("holdCompleteHandover");
    }
  },
  filters: {
    filterExportCargo(e, obj) {
      let name = "";
      obj.map((item) => {
        if (item.value == e) {
          name = item.name;
        }
      });
      return name;
    },
    deliverGoodsTypeShow(e) {
      if (e == 1) {
        return "发货出库";
      } else if (e == 2) {
        return "查验出库";
      } else if (e == 3) {
        return "整板出库";
      } else if (e == 4) {
        return "速提出库";
      } else {
        return "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.MyHandoverScreen {
  width: 100%;
  box-sizing: border-box;
  background-color: #ffffff;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
  padding: 15px 10px;

  .MyHandoverScreenItem {
    width: 100%;
    display: flex;
    margin-bottom: 10px;

    & > h1 {
      width: 75px;
      font-size: 16px;
      font-weight: 400;
      color: #999999;
      line-height: 20px;
      margin: 0;
      white-space: nowrap;
      //overflow: hidden;
      text-overflow: ellipsis;
    }

    & > p {
      font-size: 16px;
      font-weight: 400;
      color: #333;
      line-height: 20px;
      margin: 0;
      white-space: nowrap;
      //overflow: hidden;
      text-overflow: ellipsis;
    }

    & > p.red {
      color: #d91010;
    }
  }

  .button {
    border: 2px solid #f29d12;
    color: #f29d12;
    border-radius: 15px;

    img {
      vertical-align: text-bottom;
      width: 20px;
      margin-left: 2px;
    }
  }

  .button1 {
    border: 2px solid #acb7bc;
    border-radius: 15px;
  }
}
</style>
